package com.lxc.graduation.controller;

import com.lxc.graduation.entity.domain.Comment;
import com.lxc.graduation.service.CommentService;
import com.lxc.graduation.utils.JsonData;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Author: ck
 * @Description:
 * @Date: Create in 23:07 2021/2/1
 */
@RestController
@RequestMapping("/api/pub/v1/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;
    @RequestMapping("listAll")
    public JsonData listAll(@Param("topic_id") Integer topicId)
    {
        return JsonData.buildSuccess(commentService.listByTopicId(topicId));
    }

    @RequestMapping("insert")
    public JsonData insert(@RequestBody Comment comment)
    {

        comment.setCreateTime(new Date());
        commentService.insert(comment);
        return JsonData.buildSuccess("评论成功");
    }

}
